package com.mymarkdown.app.common;

import com.mymarkdown.app.common.enums.ResponseResultEnum;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;


/**
 * @author zenglun
 * @date 2021/12/5 12:20 下午
 * @description: http请求响应客户端的内容格式
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
public class ResponseResult {
    private String code;
    private String message;
    private Object data;

    public static ResponseResult empty(){
        return new ResponseResult();
    }

    public static ResponseResult ok(Object data) {
        ResponseResult empty = empty();
        empty.setCode(ResponseResultEnum.SUCCESS.getCode());
        empty.setData(data);
        empty.setMessage(ResponseResultEnum.SUCCESS.getMessage());
        return empty;
    }

    public static ResponseResult error() {
        ResponseResult empty = empty();
        empty.setCode(ResponseResultEnum.FAIL.getCode());
        empty.setMessage(ResponseResultEnum.FAIL.getMessage());
        return empty;
    }

}
